﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using freemarker.template;
using freemarker.ext.util;
using System.Collections;
using java.lang;
using ikvm.runtime;

namespace Freemarker.Net {
    public class ListModel : StringModel, TemplateModel, TemplateSequenceModel {
        public ListModel(object list, NetObjectWrapper wrapper)
            : base(list, wrapper) {
        }

        public TemplateModel get(int index) {
            var list = data as IList;

            if (index < list.Count) {
                return wrapper.wrap(list[index]);
            }
            else {
                return null;
            }
        }

        public int size() {
            var list = data as IList;
            return list.Count;
        }
    }

}
